-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): update dependency style-dictionary to v4 #2095
base: next
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2095 +/- ##
=======================================
Coverage 97.09% 97.09%
=======================================
Files 110 110
Lines 2788 2788
Branches 758 758
=======================================
Hits 2707 2707
Misses 77 77
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
56b414c
to
4f14804
Compare
4f14804
to
bbe1f9e
Compare
|
- update imports for 4.x - regenerate token values into target files - verify token build completes as expected - update doc.s
Following the migration guidelines from: https://styledictionary.com/version-4/migration/ and ran select codemods |
size-limit report 📦
|
Note: many of the output files have had their contents resequenced. Relying on the unit tests to verify no outputs have changed. To be safe, marking this one as not to merge until the next major. Also, b/c the interface for the theming tooling will change as well ( |
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. ⚠ Warning: custom changes will be lost. |
This PR contains the following updates:
^3.9.2
->^4.2.0
^3.9.2
->^4.2.0
Release Notes
amzn/style-dictionary
v4.2.0
Compare Source
Minor Changes
0fcf229
: Add a new built-in format javascript/esm that outputs an ES module JS default export.d7b5836
: Mark javascript/esm as nested, use Prettier on all JavaScript/TypeScript formats, use 3.x.x peerDependency so the user's installation is used when possible.4bf68a3
: Apply stripMeta from "json" format to the new "javascript/esm" as well.8f1b4f0
: Add new utility instyle-dictionary/utils
->stripMeta
for stripping metadata from tokens.This utility is used now as an opt-in for the built-in
'json'
format by usingoptions.stripMeta
, which if set totrue
will strip Style Dictionary meta props.You can specify
keep
/strip
(allow/blocklist) for granular control about which properties to keep or strip.Patch Changes
5e3a5af
: Update .d.ts/js files type imports to use correct extensions rather than extensionless. This fixes some incompatibilities with latest TypeScript "NodeNext" moduleResolution.v4.1.4
Compare Source
Patch Changes
a67ed31
: Pass PlatformConfig as options param to platform-applied preprocessors.19aee32
: FixconvertToBase64
util to support converting binary files such as fonts, for both Browser and NodeJS.v4.1.3
Compare Source
Patch Changes
9376247
: MakedefaultMessage
param in FileHeader type optional.43ccb42
: (#1305): fix reference sorting insortByReference
function for DTCG token format, ensuring token references are declared after their targets26728b9
: FixfilterTokens
utility to deal with random metadata properties throughout token groups, without throwing errors.v4.1.2
Compare Source
Patch Changes
e9cce6a
: Reuse static hooks in the constructor to set instance hooks prop, to avoid discarding built-in hooks overwrites by consumers.b48d0e9
: Add missing type interfaces, most notably the ExpandConfig types.v4.1.1
Compare Source
Patch Changes
5db3521
: AddiosSwiftEnumOpts.className
andiosSwiftAnyOpts.className
formats property documentation23f8a25
: Use cp and rmdir commands forcopy_assets
do and undo methods, since they affect directories, not files.v4.1.0
Compare Source
Minor Changes
ccf27b7
: Prevent duplicate redundant calls to StyleDictionary class methods by caching platform specific config & tokens results.Added reusable methods:
getPlatformTokens()
-> grabs thetokens
/allTokens
(new!exportPlatform
does not return this) for a specific platform, after running platform specific preprocessors and transforms. This replaces the oldexportPlatform
method which is now deprecated and will be removed in v5.getPlatformConfig()
-> grabs the processed/transformedPlatformConfig
for a specific platform, replaces the now deprecatedgetPlatform
method which will be removed in v5.The reasons for deprecating those methods and replacing them with new ones is to reduce method ambiguity and make them more pure.
Add new options object to methods:
getPlatformTokens
getPlatformConfig
exportPlatform
(deprecated, see above)getPlatform
(deprecated, see above)formatPlatform
formatAllPlatforms
buildPlatform
buildAllPlatforms
cleanPlatform
cleanAllPlatforms
with property
cache
, which if set tofalse
, will disable this caching of generating the platform specific config / tokens, e.g.:Expectation is that this is usually not useful for majority of users, unless for example you're testing multiple runs of StyleDictionary while changing tokens or platform configs in between those runs.
Patch Changes
2ec9a44
:size/rem
transform to leave 0 (string or number) values as is, since 0 doesn't need a unit.f317430
: Added link to logging documentation inside all of the warnings and errors that refer to verbosity.6275983
: Respectformatting
options in scss map-deep/map-flat formats, those that make sense:commentPosition
commentStyle
indentation
Also export a new type interface
FormattingOverrides
, which is a limited version ofFormattingOptions
.These contain the formatting options that can be overridden by users, whereas the full version is meant for the format helper utilities such as
createPropertyFormatter
/formattedVariables
.v4.0.1
Compare Source
Patch Changes
e6cbf73
: Fix type information for Config.parsere8aea2f
: Fix transitive color transform advanced example, migrate chroma-js to colorjs.io7afcffd
: Fix bugs with expand tokens where they would run before instead of after user-configured preprocessors, and would fatally error on broken references. Broken refs should be tolerated at the expand stage, and errors will be thrown after preprocessor lifecycle if the refs are still broken at that point.922b6aa
: Update memfs esm-fork dependency to allow named import Volume.61b6984
: Fix 'filePath' missing from falsy token values3ae67e3
: Upgrade memfs esm fork to publish types and bumping stream to fix unclear licensing issue with transitive dependency.v4.0.0
Compare Source
Major Changes
6cc7f31
: BREAKING:usesReference
util function is nowusesReferences
to be consistent plural form like the other reference util functions.getReferences
first and second parameters have been swapped to be consistent withresolveReferences
, so value first, then the full token object (instead of the entire dictionary instance).getReferences
accepts a third options parameter which can be used to set reference Regex options as well as an unfilteredTokens object which can be used as a fallback when references are made to tokens that have been filtered out. There will be warnings logged for this.format.formatter
removed old function signature of(dictionary, platform, file)
in favor of({ dictionary, platform, options, file })
.Types changes:
.d.ts
files published next to every file, this means that if you import from one of Style Dictionary's entrypoints, you automatically get the types implicitly with it. This is a big win for people using TypeScript, as the majority of the codebase now has much better types, with much fewerany
s.index.d.ts
anymore that exposes all type interfaces on itself. This means that you can no longer grab types that aren't members of the Style Dictionary class directly from the default export of the main entrypoint. External types such asParser
,Transform
,DesignTokens
, etc. can be imported from the newly added types entrypoint:Please raise an issue if you find anything missing or suddenly broken.
Matcher
,Transformer
,Formatter
, etc. are still available, although no longer directly but rather as properties on their parents, soFilter['matcher']
,Transform['transformer']
,Format['formatter']
dcbe2fb
: - The project has been fully converted to ESM format, which is also the format that the browser uses.For users, this means you'll have to either use Style Dictionary in ESM JavaScript code, or dynamically import it into your CommonJS code.
StyleDictionary.extend()
method is now asynchronous, which means it returnsPromise<StyleDictionary.Core>
instead ofStyleDictionary.Core
.allProperties
/properties
was deprecated in v3, and is now removed fromStyleDictionary.Core
, useallTokens
andtokens
instead.registerTemplate
were deprecated in v3, now removed. Use Formats instead.style-dictionary
&style-dictionary/fs
. If more is needed, please raise an issue explaining which file you were importing and why you need it to be public API.f2ed88b
: BREAKING: File headers, when registered, are put inside thehooks.fileHeaders
property now, as opposed tofileHeader
.Note the change from singular to plural form here.
Before:
After:
79bb201
: BREAKING: Logging has been redesigned a fair bit and is more configurable now.Before:
After:
Log is now and object and the old "log" option is now "warnings".
This configures whether the following five warnings will be thrown as errors instead of being logged as warnings:
Verbosity configures whether the following warnings/errors should display in a verbose manner:
And it also configures whether success/neutral logs should be logged at all.
Using "silent" (or --silent in the CLI) means no logs are shown apart from fatal errors.
f2ed88b
: BREAKING: Actions, when registered, are put inside thehooks.actions
property now, as opposed toaction
.Note the change from singular to plural form here.
Before:
After:
a4542f4
: BREAKING: StyleDictionaryInstance.properties & .allProperties have been removed. They were deprecated in v3 in favor of .tokens and .allTokens.5e167de
: BREAKING: movedformatHelpers
away from the StyleDictionary class and export them in'style-dictionary/utils'
entrypoint instead.Before
After
f2ed88b
: Filters, when registered, are put inside thehooks.filters
property now, as opposed tofilter
.Note the change from singular to plural form here.
Before:
After:
In addition, when using
registerFilter
method, the name of the filter function is nowfilter
instead ofmatcher
.Before:
After:
f2ed88b
: BREAKING: Transform groups, when registered, are put inside thehooks.transformGroups
property now, as opposed totransformGroup
.Before:
After:
502dbd1
: BREAKING: All of our hooks, parsers, preprocessors, transforms, formats, actions, fileHeaders and filters, support async functions as well now. This means that the formatHelpers -> fileHeader helper method is now asynchronous, to support async fileheader functions.f2ed88b
: BREAKING: Formats, when registered, are put inside thehooks.formats
property now, as opposed toformat
.The
formatter
handler function has been renamed toformat
for consistency.The importable type interfaces have also been renamed,
Formatter
is nowFormatFn
andFormatterArguments
is nowFormatFnArguments
.Note that you can also use
Format['format']
instead ofFormatFn
, orParameters<Format['format']>
instead ofFormatFnArguments
, so these renames may not matter.Before:
After:
e83886c
: BREAKING: preprocessors must now also be explicitly applied on global or platform level, rather than only registering it. This is more consistent with how the other hooks work and allows applying it on a platform level rather than only on the global level.preprocessors
property that contains the registered preprocessors has been moved under a wrapping property calledhooks
.Before:
After:
2f80da2
: BREAKING:className
,packageName
,mapName
,type
,name
,resourceType
andresourceMap
options for a bunch of built-in formats have been moved fromfile
to go inside thefile.options
object, for API consistency reasons.Before:
After:
f2ed88b
: BREAKING: Transforms, when registered, are put inside thehooks.transforms
property now, as opposed totransform
.The
matcher
property has been renamed tofilter
(to align with the Filter hook change), and thetransformer
handler function has been renamed totransform
for consistency.Before:
After
90095a6
: BREAKING: Allow specifying afunction
foroutputReferences
, conditionally outputting a ref or not per token. Also exposesoutputReferencesFilter
utility function which will determine whether a token should be outputting refs based on whether those referenced tokens were filtered out or not.If you are maintaining a custom format that allows
outputReferences
option, you'll need to take into account that it can be a function, and pass the correct options to it.Before:
After
122c8f6
: BREAKING: expose getReferences and usesReference utilities as standalone utils rather than requiring them to be bound to dictionary object. This makes it easier to use.0b81a08
: BREAKING: no longer wraps tokens of type asset in double quotes. Rather, we added a transformasset/url
that will wrap such tokens insideurl("")
statements, this transform is applied to transformGroups scss, css and less.a4542f4
: BREAKING: StyleDictionary to be initialized with a new API and have async methods. Use:You can still extend a dictionary instance with an extended config, but
.extend()
is only used for this, it is no longer used to initialize the first instance:To ensure your initialized StyleDictionary instance is fully ready and has imported all your tokens, you can await
hasInitialized
:For error handling and testing purposes, you can also manually initialize the style-dictionary config:
The main reason for an initialize step after class instantiation is that async constructors are not a thing in JavaScript, and if you return a promise from a constructor to "hack it", TypeScript will eventually trip over it.
Due to being able to dynamically (asynchronously) import ES Modules rather than synchronously require CommonJS modules, we had to make the APIs asynchronous, so the following methods are now async:
In a future release, most other methods will be made async or support async as well, such as parsers, transforms, formats etc.
f2ed88b
: BREAKING: Parsers, when registered, are put inside thehooks.parsers
property now, as opposed toparsers
.parsers
property has been repurposed: you will now also need to explicitly apply registered parsers by name in theparsers
property, they no longer apply by default.When registering a parser, you must also supply a
name
property just like with all other hooks, and theparse
function has been renamed toparser
for consistency.Before:
After:
bcb5ef3
: Remove reliance on CTI token structure across transforms, actions and formats.Breaking changes:
attributes.category
as the token type indicator.name/cti/casing
to justname/casing
.name/ti/camel
andname/ti/constant
have been removed. For examplename/cti/kebab
transform is nowname/kebab
.content/icon
has been renamed tohtml/icon
since it targets HTML entity strings, not just any icon content.font/objC/literal
,font/swift/literal
andfont/flutter/literal
have been removed in favor offont/objC/literal
,font/swift/literal
andfont/flutter/literal
, as they do he exact same transformations.typescript/module-declarations
format to be updated with current DesignToken type interface.Before:
After:
7b82150
: BREAKING: For formats using thefileHeader
formatHelpers
utility, it will no longer display a timestamp in the fileHeader output by default. This is now an opt-in by settingfile.formatting.fileHeaderTimestamp
totrue
. The reason for making this opt-in now is that using Style Dictionary in the context of a CI (continuous integration) pipeline is a common use-case, and when running on pull request event, output files always show a diff in git due to the timestamp changing, which often just means that the diff is bloated by redundancy.New:
or:
Minor Changes
39f0220
: Allow not throwing fatal errors on broken token references/aliases, butconsole.error
instead.You can also configure this on global/platform
log
property:This setting defaults to
"error"
when not configured.resolveReferences
andgetReferences
warnImmediately
option is set totrue
which causes an error to be thrown/warned immediately by default, which can be configured tofalse
if you know those utils are running in the transform/format hooks respectively, where the errors are collected and grouped, then thrown as 1 error/warning instead of multiple.Some minor grammatical improvements to some of the error logs were also done.
8450a45
: Some fixes for Expand utility:dashArray
property ofstrokeStyle
tokens no longer get expanded unintentionally,typeof 'object'
check changed toisPlainObject
check.style
property insideborder
tokens) will now also be expanded.This is because if the reference is to an object value, the expansion might break the reference.
c06661d
: Re-add and update example basic, fix copySync command in CLI, fix android templates to use $type for DTCG tokens.dcbe2fb
: FileSystem that is used by Style Dictionary can now be customized:By default, it uses an in-memory filesystem shim
@bundled-es-modules/memfs
in browser context,node:fs
built-in module in Node context.3485467
: Fix some inconsistencies in some of the templates, usually with regards to spaces/newlines606af51
: RenametypeW3CDelegate
utility function totypeDtcgDelegate
, as using "W3C" is highly discouraged when the standard isn't a W3C standard yet.4225d78
: Added the following transforms for CSS, and added them to thescss
,css
andless
transformGroups:fontFamily/css
-> wraps font names with spaces in'
quotescubicBezier/css
-> array value, put insidecubic-bezier()
CSS functionstrokeStyle/css/shorthand
-> object value, transform to CSS shorthandborder/css/shorthand
-> object value, transform to CSS shorthandtypography/css/shorthand
-> object value, transform to CSS shorthandtransition/css/shorthand
-> object value, transform to CSS shorthandshadow/css/shorthand
-> object value (or array of objects), transform to CSS shorthandThe main intention here is to ensure that Style Dictionary is compliant with DTCG draft specification out of the box with regards to exporting to CSS, where object-value tokens are not supported without transforming them to shorthands (or expanding them, which is a different feature that was added in
4.0.0-prerelease.27
).cedf8a0
: Preprocessors are a new feature added to style-dictionary, which allows you to do any type of processing of the token dictionary after parsing, before resolving and transforming.See preprocessor docs for more information.
cb94554
: 'size/rem' transform to not transform tokens that already have a unit, such as"4px"
, this should not be transformed to"4rem"
.a4542f4
: options.log to be respected in all error logging, including platform specific logs.122c8f6
: Expose a new utility called resolveReferences which takes a value containing references, the dictionary object, and resolves the value's references for you.0410295
: Improve and test the error handling of standalone usage of reference utilities.8b6fff3
: Fixes some noisy warnings still being outputted even when verbosity is set to default.We also added log.warning "disabled" option for turning off warnings altogether, meaning you only get success logs and fatal errors.
This option can be used from the CLI as well using the
--no-warn
flag.2da5130
: AddedoutputReferencesTransformed
utility function to pass into outputReferences option, which will not output references for values that have been transitively transformed.606af51
: Support the use of "value"/"type"/"description" as token names or token group names, at the sacrifice of now no longer being able to combine non-DTCG and DTCG syntax within the same token dictionary.7418c97
: Add a couple of utilities for converting a regular Style Dictionary tokens object/file(s) to DTCG formatted tokens:convertToDTCG
convertJSONToDTCG
convertZIPToDTCG
Documentation of these utilities
294fd0e
: Support Design Token Community Group Draft specification for Design Tokens, by adding support for $value, $type and $description properties.aff6646
: Allow passing a custom FileSystem Volume to your Style Dictionary instances, to ensure input/output files are read/written from/to that specific volume.Useful in case you want multiple Style Dictionary instances that are isolated from one another in terms of inputs/outputs.
This also works when using extend:
261a2cb
: Handle transition timingFunction prop in cubicBezier/css transform. Handle typography fontFamily prop in fontFamily/css transform.e83886c
: Allow expanding tokens on a global or platform-specific level. Supports conditionally expanding per token type, or using a function to determine this per individual token.af5cc94
: CreateformatPlatform
andformatAllPlatforms
methods.This will return the outputs and destinations from the format hook for your dictionary, without building these outputs and persisting them to the filesystem.
Additionally, formats can now return any data type instead of requiring it to be a
string
anddestination
property infiles
is now optional.This allows users to create formats intended for only formatting tokens and letting users do stuff with it during runtime rather than writing to files.
c06661d
: Re-add and update example basic, fix copySync command in CLI, fix android templates to use $type for DTCG tokens.4556712
: Make css transforms for strokeStyle, cubicBezier and fontFamily transitive, to deal with the use case where they are used within border, transition and typography tokens and those tokens have other properties that contain references.Patch Changes
894f37c
: Update glob esm browser fork to latest, resolve unclear licensing issue.cb78c3d
: UpdatetypeDtcgDelegate
utility to remove the $type on token group level between parsing/preprocessing step.5079154
: Fix deepExtend util bug with overriding behavior for tokens.c1dd5ec
: Allow overriding CSS formatting with commentStyle and commentPosition props.For commentStyle, options are 'short' or 'long'.
For commentPosition, options are 'above' or 'inline'.
We also ensure that the right defaults are picked for CSS, SASS/SCSS, Stylus and Less.
This also contains a fix for ensuring that multi-line comments are automatically put "above" rather than "inline".
2f80da2
: All formats usingcreatePropertyFormatter
orformattedVariables
helpers now respect thefile.options.formatting
option passed by users to customize formatting.Example:
24584b4
: Conditionally only run dev scripts when CWD is style-dictionary, so our consumers don't run it by accident044123c
: Patch StyleDictionary main type file to export default instead of "export =" which does not work in ESM.cb94554
: Fix typeDtcgDelegate util $type property position to be allowed anywhere in the object, not just at the top.8e297d6
: Fix outputReferences for DTCG spec tokens, by using token.original.$value instead of token.original.value.59f3eb0
: Expose flattenTokens utility.72f020d
: Pass outputReferenceFallbacks option to the relevant utilities, so the option actually works.39547fb
: Fix parsers async support, use resolved filePath instead of raw.3138313
: Allow transitive transforms to return undefined, by doing this the transformer can mark itself as "deferred" for that specific token. This is useful when references in properties other than "value" need to be resolved first.cd9f484
: Escape double quotes for ts outputStringLiterals0c1a36f
: Fix small issue in type DTCG delegate utility type tracking.d008c67
: Fix a couple of spots where DTCG option wasn't properly taken into account, more tests added.6cfce97
: Fix logging to be ordered by platform when building or cleaning platforms. This now happens in parallel, resulting in the logs being ordered randomly which was a small regression to the logging experience.6fb81ad
: Allow falsy token values for outputReferences, e.g.0
.0972b26
: Pass SD options to fileheaders and filters, to make it easier to use and adjust according to config or options like usesDTCG.2335f13
: Allow using registerHook methods to override hooks that are already registered with the same name.24d41c3
: Allow outputReferences to work on non-string values.0c1a36f
: ExposetypeDtcgDelegate
utility. Don't takevalue
into account anymore to determine that it's a design token, use$value
.061c67e
: Hotfix to address outputReferencesTransformed util not handling object-value tokens properly.8d2f6d8
: Make sure fs-node.js file is published to NPM.738686b
: Allow transformGroup to be combined with transforms, where standalone transforms will be added after the group's transforms.c708325
: Moving the @zip.js/zip.js dependency from a devDependency to a normal dependency.cd48aac
: Only run postinstall scripts when NODE_ENV isn't production (e.g. npm install --production or --omit=dev). To avoid errors running husky/patch-package.a5bafac
: Colors that are not recognized by tinycolor2 as valid color formats (e.g.linear-gradient(...)
) are now ignored by the builtin color transforms filter functions.4ec34fd
: Pass options to all of the filter functions in our built-in transforms, to check forusesDTCG
and$type
property.daa78e1
: fix(types): Added missing type exportse859036
: Fix Windows support by using a Linux/Windows + Node/Browser compatible path utility. Upgrade to latest Glob version. Apply posix: true to prevent breaking change glob update.6e226aa
: Pass the original ref path to thegetReferences
util result tokens.1dd828c
: Fix issue in browser-bundled glob, bump.3f09277
: Pass dictionary options to preprocessor functions.c2cbd1b
: Publish the postinstall-dev script to NPM.0972b26
: Add unfilteredAllTokens property in dictionary object for formats, which is an unfiltered version of allTokens property, or a flattened version of the unfilteredTokens property.47face0
: Token merging behavior changed so that upon token collisions, metadata props aren't accidentally merged together.f8c40f7
: fix(types): add missing type keyword for type export from index.d.ts77ae35f
: Fix scenario of passing absolute paths in Node env, do not remove leading slash in absolute paths.63681a6
: Fix a couple of type imports issues in .d.ts files261a2cb
: Allow border type tokens to be empty, every property is optional.ba03ee9
: Fix for expand utility on platform level to adjust the token's path property.All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
3.9.2 (2024-01-17)
Bug Fixes
3.9.1 (2023-12-07)
Bug Fixes
This PR has been generated by Renovate Bot.